function  crisis_sparse_vec =  gen_sparse_crisis( crisis_vec,  distance )
% Note: the input "crisis_vec" is a vector of true/false that indicates a crisis. This function removes the consecutive
% crisis with distance smaller than the range, so that we obtain non-clustered crisis. 
  
crisis_index = find(crisis_vec==1);
crisis_sparse_vec = crisis_vec ;
crisis_last = crisis_index(1);

for( iter = 2:length(crisis_index) )
    index = crisis_index(iter);
    if(index-crisis_last<distance)
        crisis_sparse_vec(index) = 0;
    else
        crisis_sparse_vec(index) = 1;
        crisis_last = index;
    end
end


